import { Component } from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {WgLoading} from "../../widget/widget_Loading";
import {WgActionSheet} from "../../widget/widget_ActionSheet";
import {WgAlert} from "../../widget/widget_Alert";
import {ZQHToast} from "../../util/zqhToast";
import {ZQHNFC} from "../../util/zqhNFC";
import {ZQHCamera} from "../../util/zqhCamera";
/**
 * Generated class for the MePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-me',
  templateUrl: 'me.html',
})
export class MePage {

  selectPicture = [];
  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  showLoading(){
    WgLoading.showLoading();
    setTimeout(() => {
      WgLoading.hideLoading();
    }, 3000);
  }

  presentActionSheet(){
    WgActionSheet.presentActionSheet(index =>{
      if(index == 0){
        //拍照
        ZQHCamera.cameraGetPicture(files =>{
          for(let file of files){
            this.selectPicture.push(file);
          }
        })
      }else if(index == 1){
        //相册
        ZQHCamera.getPictures(4-this.selectPicture.length,files =>{
          for(let file of files){
            this.selectPicture.push(file);
          }
        })
      }
    });

  }

  showPrompt() {
   WgAlert.confirmAlert("确认退出吗?",result =>{
     console.log(result);
   });
  }

  showToast(){
    ZQHToast.showShortCenter("你好!");
  }

  readNFC(){
    ZQHNFC.readNFC(result => {
      ZQHToast.showShortCenter(result);
    })
  }

}
